package com.yiqi.zhiyuan.feature.msg.model;

import com.suozhang.framework.component.http.RxDataProcessFactory;
import com.suozhang.framework.entity.bo.PageData;
import com.yiqi.zhiyuan.entity.vo.MessageTypeVO;
import com.yiqi.zhiyuan.entity.vo.MsgVO;
import com.yiqi.zhiyuan.feature.msg.contract.MessageContract;
import com.yiqi.zhiyuan.feature.msg.dependencies.message.DaggerMessageModelComponent;
import com.yiqi.zhiyuan.framework.api.ApiLib;
import com.yiqi.zhiyuan.framework.api.MsgApi;

import java.util.List;

import javax.inject.Inject;

import io.reactivex.Observable;

/**
 * @ProjectName: ZhiYuan
 * @Description: 注册model
 * @Author: lijuwen
 * @CreateDate: 2019/3/13 13:07
 * @UpdateUser: 更新者
 * @UpdateDate: 2019/3/13 13:07
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class MessageModel implements MessageContract.Model {
    @Inject
    MsgApi api;

    public MessageModel() {
        DaggerMessageModelComponent.builder().apiComponent(ApiLib.apiComponent()).build().inject(this);
    }



    @Override
    public Observable<MsgVO> doNotification() {
        return api.notification().compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<PageData<MessageTypeVO>> doMessageList(int type, int page) {
        return api.messageList(type,page).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }
}

